<?php
/**
 * Description of userArtikelFormclass
 *
 * @author destiya
 */
class userArtikelForm extends BaseartikelForm {

    public function configure() {
        $this->useFields(array('judul', 'isi', 'id_penulis', 'id_bidang_studi'));

        $this->setWidget('isi', new sfWidgetFormTextarea());
        $this->setWidget('id_penulis', new sfWidgetFormInputHidden());
        

        $this->widgetSchema['id_bidang_studi'] = new sfWidgetFormChoice(array(
            'choices'=>Doctrine_Core::getTable('setBidangStudi')->getListBidangStudi(),
            'expanded'=>false,
            'multiple'=>false
        ));

        $this->validatorSchema['judul'] = new sfValidatorAnd(array(
            $this->validatorSchema['judul'], new sfValidatorString(
                        array('trim'=>true, 'max_length' => 150, 'min_length' => 4),
                        array('required' => 'Judul Artikel harus diisi',
                                'max_length' => 'Judul Artikel maksimal 150 karakter',
                                'min_length' => 'Judul Artikel minimal 4 karakter'
                            )
                    )
        ));

        $this->validatorSchema['isi'] = new sfValidatorAnd(array(
            $this->validatorSchema['isi'], new sfValidatorString(
                        array('trim' => true),
                        array('required' => 'Artikel harus diisi')
                    )
        ));

        $this->validatorSchema['id_bidang_studi'] = new sfValidatorChoice(array(
            'choices' => array_keys(Doctrine_Core::getTable('setBidangStudi')->getListBidangStudi())
        ));

        
    }

    public function setIdPenulis($value) {
        $this->setDefault('id_penulis', $value);
    }
}
?>
